﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using S3.DataModel;
using S3.Common;

namespace S3.Biz
{
    /// <summary>
    /// Phien lam viec cua nhan vien.
    /// </summary>
    public class WorkSessionManager : CommonManager
    {
        public bool DoHandOver(string handOverBy)
        {            
            try
            {
                WorkSession workSession = new WorkSession()
                {
                    HandOverBy = handOverBy,
                    HandOverTime = DateTime.Now,
                    Status = WorkSessionStatusValue.Text[WorkSessionStatus.Waiting]
                };

                _entities.AddToWorkSessions(workSession);
                _entities.SaveChanges();
            }
            catch (Exception ex)
            {
                using (var exception = new SSDLoggingHandler())
                {
                    exception.BizException("WorkSessionManager::DoHandOver::", ex, true);
                }
                return false;
            }

            return true;
        }
    }
}
